home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / musicmixer / src / mixer / display / soloablechannels.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  1.4 KB  |  54 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. package mixer.display;
  9.  
  10. import java.awt.*;
  11. import java.util.*;
  12. import javax.swing.*;
  13.  
  14. import quicktime.*;
  15. import quicktime.app.audio.*;
  16.  
  17. import mixer.mc.*;
  18.  
  19. /** This class is a wrapper to group all of the sound types that can be soloed.  A channel
  20.  *  that can be soloed needs to know which control it came from because that is the only
  21.  *  object who can find all of its sibling channels and solo out the correct ones.
  22.  */
  23. public class SoloableChannels extends JPanel {
  24.     private MixerComponents[] channels;
  25.     private int soloCount = 0;
  26.     
  27.     public SoloableChannels (MixerComponents[] mc) throws QTException {
  28.         channels = mc;
  29.  
  30.         if (channels != null) {
  31.             for (int i = 0; i < channels.length; i++) {
  32.                 ChannelDisplay channel = new SoundTrackDisplay (this, channels[i]);
  33.                 add(channel);
  34.             }
  35.         }
  36.     }
  37.     
  38.     /* When a child changes its solo state, it invokes this method with its new solo
  39.      * state.  This method then calls the doSolo method on each child to get the actual
  40.      * work of soloing completed.
  41.      */
  42.     void setSolo (boolean set) throws QTException {
  43.         if (channels == null) return;
  44.         
  45.         if (set)
  46.             soloCount++;
  47.         else
  48.             soloCount--;
  49.     
  50.         Component[] ar = getComponents();
  51.         for (int i = 0; i < ar.length; i++)
  52.             ((SoundTrackDisplay)ar[i]).doSolo (soloCount);
  53.     }
  54. }